<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>


<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.List" %>
<%@ page import="com.cn.*" %>
<%@ page import="com.cn.Dao.*" %>
<%@ page import="com.cn.entity.*" %>
<jsp:include page="WEB-INF/header/header-admin.jsp"/>
<jsp:useBean id="userInfo" class="com.cn.entity.UserInfo" scope="session"/>
<%
    List<BookUnion> bookUnions= (List<BookUnion>) request.getSession().getAttribute("bookUnions");
    List<NewsInfo> newsInfos=new NewsinfoDao().findAll();
    Float total=0f;
%>

<html lang="en">
<head>
    <meta charset="utf-8">
    <title>订单统计 </title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
    <link rel="shortcut icon" href="<%=request.getContextPath()%>/img/logo2.png" type="image/x-icon">
</head>
<body>
<div class="container-fluid">
    <form action="BookStatisticsServlet" method="post">
        <div class="row">
            <div class="col-md-2">
                <div class="row">
                    <div class="col-md-4">
                        <label class="float-right">报刊</label>
                    </div>
                    <div class="col-xs-9 text-left">
                    <select name="bk">
                        <option selected></option>
                        <%for(int i=0;i<newsInfos.size();i++){%>
                        <option value="<%=newsInfos.get(i).getNum()%>"><%=newsInfos.get(i).getName()%></option>
                        <%}%>
                    </select>
                    </div>
                </div>
            </div>
            <div class="col-md-2">
                <div class="row">
                    <div class="col-md-4">
                        <label class="float-right">用户</label>
                    </div>
                    <div class="col-xs-9 text-left">
                    <select id="yh" name="yh">
                        <option selected></option>
                        <c:forEach items="${userInfos}" var="userInfo">
                            <option value="${userInfo.getUsername()}">${userInfo.getName()}</option>
                        </c:forEach>
                    </select>
                    </div>
                </div>
            </div>
            <div class="col-md-2">
                <div class="row">
                    <div class="col-md-6">
                        <label class="float-right">部门</label>
                    </div>
                    <div class="col-xs-9 text-left">
                        <select id="dep" name="dep">
                            <option selected></option>
                            <c:forEach items="${depInfos}" var="depInfo">
                                <option value="${depInfo.getDepartmentid()}">${depInfo.getDname()}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
            </div>

            <div class="col-md-2">
                <br/>
                <button class="btn btn-primary btn-large" type="submit" name="submit">确定</button>
            </div>
            <a href="printStatPage.jsp" target="_blank">
            <div class="col-md-2">
                <br/>
                <button class="btn btn-primary btn-large" type="button">打印预览</button>
            </div>
            </a>
        </div>
    </form>
    <div class="row">
        <div class="col-md-12">
            <table class="table table-hover">
                <thead>
                <tr>
                    <th>
                        #
                    </th>
                    <th>
                        用户
                    </th>
                    <th>
                        报刊名称
                    </th>
                    <th>
                        订阅份数
                    </th>
                    <th>
                        订阅月数
                    </th>
                    <th>
                        总金额
                    </th>
                </tr>
                </thead>
                <tbody>
                <%for(int i=0;i<bookUnions.size();i++){
                    total+=bookUnions.get(i).getPrice();
                %>
                <tr>
                    <td>
                        <%=bookUnions.get(i).getBid()%>
                    </td>
                    <td>
                        <%=bookUnions.get(i).getUsername()%>
                    </td>
                    <td>
                        <%=bookUnions.get(i).getNewsname()%>
                    </td>
                    <td>
                        <%=bookUnions.get(i).getAmount()%>
                    </td>
                    <td>
                        <%=bookUnions.get(i).getMonth()%>
                    </td>
                    <td>
                        <%=bookUnions.get(i).getPrice()%>
                    </td>
                </tr>
                <%}%>
                <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>
                        总计:<%=total%>元
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/scripts.js"></script>
</body>
</html>


